package com.guys8.cemsbackend.DTO;

import com.guys8.cemsbackend.entity.Health;
import com.guys8.cemsbackend.entity.Nacid;
import com.guys8.cemsbackend.entity.User;
import lombok.Getter;
import lombok.Setter;

import java.text.SimpleDateFormat;
import java.util.Date;

@Getter
@Setter
public class User_health_nacid {
    String schoolid;
    String name;
    String datetime;
    Integer state;

    public User_health_nacid(){}
    public User_health_nacid(Health health, Nacid nacid, User user){
        setSchoolid(user.getSchoolId());
        setName(user.getUserName());

        if(nacid==null) setDatetime("暂无核算记录");
        else {
            Date date = nacid.getNacidTime();
            String pattern = "yyyy年MM月dd日 HH:mm:ss";
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
            setDatetime(simpleDateFormat.format(date));
            System.out.println(datetime);
        }
        if(health==null) setState(4);
        else {
            String hcode = health.getHcode();
            switch (hcode) {
                case "绿码": setState(0); break;
                case "黄码": setState(1); break;
                case "红码": setState(2); break;
            }
        }
    }
}
